from gi.repository import GLib

import dbus
import dbus.service
import dbus.mainloop.glib

import subprocess

def hello_signal_handler(hello_string):
    print ("Received signal (by connecting using remote object) and it says: " + hello_string)


if __name__ == "__main__":
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

    bus = dbus.SessionBus()
    proxy = bus.get_object("com.example.TestService","/com/example/TestService/object")
    proxy.connect_to_signal("HelloSignal", 
                            hello_signal_handler, 
                            dbus_interface="interface.TestService", 
                            arg0="Hello")  # String argument matching

    loop = GLib.MainLoop()
    print("Running example signal emitter service.")
    loop.run()